package org.admanager.piadladmapping.plugin.diagram.providers;

import org.admanager.piadladmanagement.plugin.piadladmanagement.PiadladmanagementPackage;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.ArchitectureName2EditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.ArchitectureNameEditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.CBAPatternNameEditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.ComponentNameEditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.ConnectorNameEditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.PComponentName2EditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.PComponentNameEditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.PConnectorName2EditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.PConnectorNameEditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.PConstraintNameEditPart;
import org.admanager.piadladmapping.plugin.diagram.edit.parts.PRoleNameEditPart;
import org.admanager.piadladmapping.plugin.diagram.parsers.MessageFormatParser;
import org.admanager.piadladmapping.plugin.diagram.part.PiADLADManagementMetamodelVisualIDRegistry;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
import org.eclipse.gmf.runtime.notation.View;

/**
 * @generated
 */
public class PiADLADManagementMetamodelParserProvider extends AbstractProvider
		implements IParserProvider {

	/**
	 * @generated
	 */
	private IParser cBAPatternName_5031Parser;

	/**
	 * @generated
	 */
	private IParser getCBAPatternName_5031Parser() {
		if (cBAPatternName_5031Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getCBAPattern_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			cBAPatternName_5031Parser = parser;
		}
		return cBAPatternName_5031Parser;
	}

	/**
	 * @generated
	 */
	private IParser architectureName_5035Parser;

	/**
	 * @generated
	 */
	private IParser getArchitectureName_5035Parser() {
		if (architectureName_5035Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			architectureName_5035Parser = parser;
		}
		return architectureName_5035Parser;
	}

	/**
	 * @generated
	 */
	private IParser pRoleName_5026Parser;

	/**
	 * @generated
	 */
	private IParser getPRoleName_5026Parser() {
		if (pRoleName_5026Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getPRole_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			pRoleName_5026Parser = parser;
		}
		return pRoleName_5026Parser;
	}

	/**
	 * @generated
	 */
	private IParser pConstraintName_5025Parser;

	/**
	 * @generated
	 */
	private IParser getPConstraintName_5025Parser() {
		if (pConstraintName_5025Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getPConstraint_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			pConstraintName_5025Parser = parser;
		}
		return pConstraintName_5025Parser;
	}

	/**
	 * @generated
	 */
	private IParser pComponentName_5029Parser;

	/**
	 * @generated
	 */
	private IParser getPComponentName_5029Parser() {
		if (pComponentName_5029Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getPElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			pComponentName_5029Parser = parser;
		}
		return pComponentName_5029Parser;
	}

	/**
	 * @generated
	 */
	private IParser pComponentName_5028Parser;

	/**
	 * @generated
	 */
	private IParser getPComponentName_5028Parser() {
		if (pComponentName_5028Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getPElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			pComponentName_5028Parser = parser;
		}
		return pComponentName_5028Parser;
	}

	/**
	 * @generated
	 */
	private IParser pConnectorName_5027Parser;

	/**
	 * @generated
	 */
	private IParser getPConnectorName_5027Parser() {
		if (pConnectorName_5027Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getPElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			pConnectorName_5027Parser = parser;
		}
		return pConnectorName_5027Parser;
	}

	/**
	 * @generated
	 */
	private IParser pConnectorName_5030Parser;

	/**
	 * @generated
	 */
	private IParser getPConnectorName_5030Parser() {
		if (pConnectorName_5030Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getPElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			pConnectorName_5030Parser = parser;
		}
		return pConnectorName_5030Parser;
	}

	/**
	 * @generated
	 */
	private IParser componentName_5034Parser;

	/**
	 * @generated
	 */
	private IParser getComponentName_5034Parser() {
		if (componentName_5034Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			componentName_5034Parser = parser;
		}
		return componentName_5034Parser;
	}

	/**
	 * @generated
	 */
	private IParser architectureName_5033Parser;

	/**
	 * @generated
	 */
	private IParser getArchitectureName_5033Parser() {
		if (architectureName_5033Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			architectureName_5033Parser = parser;
		}
		return architectureName_5033Parser;
	}

	/**
	 * @generated
	 */
	private IParser connectorName_5032Parser;

	/**
	 * @generated
	 */
	private IParser getConnectorName_5032Parser() {
		if (connectorName_5032Parser == null) {
			EAttribute[] features = new EAttribute[] { PiadladmanagementPackage.eINSTANCE
					.getElement_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			connectorName_5032Parser = parser;
		}
		return connectorName_5032Parser;
	}

	/**
	 * @generated
	 */
	protected IParser getParser(int visualID) {
		switch (visualID) {
		case CBAPatternNameEditPart.VISUAL_ID:
			return getCBAPatternName_5031Parser();
		case ArchitectureNameEditPart.VISUAL_ID:
			return getArchitectureName_5035Parser();
		case PRoleNameEditPart.VISUAL_ID:
			return getPRoleName_5026Parser();
		case PConstraintNameEditPart.VISUAL_ID:
			return getPConstraintName_5025Parser();
		case PComponentNameEditPart.VISUAL_ID:
			return getPComponentName_5029Parser();
		case PComponentName2EditPart.VISUAL_ID:
			return getPComponentName_5028Parser();
		case PConnectorNameEditPart.VISUAL_ID:
			return getPConnectorName_5027Parser();
		case PConnectorName2EditPart.VISUAL_ID:
			return getPConnectorName_5030Parser();
		case ComponentNameEditPart.VISUAL_ID:
			return getComponentName_5034Parser();
		case ArchitectureName2EditPart.VISUAL_ID:
			return getArchitectureName_5033Parser();
		case ConnectorNameEditPart.VISUAL_ID:
			return getConnectorName_5032Parser();
		}
		return null;
	}

	/**
	 * Utility method that consults ParserService
	 * @generated
	 */
	public static IParser getParser(IElementType type, EObject object,
			String parserHint) {
		return ParserService.getInstance().getParser(
				new HintAdapter(type, object, parserHint));
	}

	/**
	 * @generated
	 */
	public IParser getParser(IAdaptable hint) {
		String vid = (String) hint.getAdapter(String.class);
		if (vid != null) {
			return getParser(PiADLADManagementMetamodelVisualIDRegistry
					.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(PiADLADManagementMetamodelVisualIDRegistry
					.getVisualID(view));
		}
		return null;
	}

	/**
	 * @generated
	 */
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (PiADLADManagementMetamodelElementTypes.getElement(hint) == null) {
				return false;
			}
			return getParser(hint) != null;
		}
		return false;
	}

	/**
	 * @generated
	 */
	private static class HintAdapter extends ParserHintAdapter {

		/**
		 * @generated
		 */
		private final IElementType elementType;

		/**
		 * @generated
		 */
		public HintAdapter(IElementType type, EObject object, String parserHint) {
			super(object, parserHint);
			assert type != null;
			elementType = type;
		}

		/**
		 * @generated
		 */
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return elementType;
			}
			return super.getAdapter(adapter);
		}
	}

}
